package com.hawthorn.admin.controller.showUserApply;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hawthorn.admin.service.showUserApply.ShowUserApplyService;
import com.hawthorn.platform.utils.common.MyUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @version v1.0.1
 * @Copyright: Copyright (c) $
 * @remark: TODO 演示账号维护Controller层
 * @author:zhangzhexu
 * @date:2023/3/21$ 13:18$
 */
@Api(tags = {"base-show-user-apply"})
@RestController
@RequestMapping("/showUserApply")
public class ShowUserApplyController
{
  @Resource
  private ShowUserApplyService showUserApplyService;

  @ApiOperation(value = "查询->演示账号信息", notes = "查询演示账号信息 带分页")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "params", value = "查询条件参数", dataTypeClass = String.class)
  })
  @PostMapping(value = "/findShowUserApply")
  public IPage<Map<String, Object>> findShowUserApply(@RequestBody String params)
  {
    Page<Map<String, Object>> page = new Page<>();
    String conditions = MyUtil.getConditionsWhere(params, page);
    return showUserApplyService.findShowUserApply(page, conditions);
  }

  @ApiOperation(value = "修改->演示账号状态", notes = "修改演示账号状态")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "id", value = "主键", dataTypeClass = Long.class),
  })
  @PostMapping(value = "/updateShowUserStatus/{id}")
  public Integer updateShowUserStatus(@PathVariable("id") Long id, @RequestBody Map<String, Object> param)
  {
    return showUserApplyService.updateShowUserStatus(id, param);
  }

  @ApiOperation(value = "查询->演示账号更新日志信息分页", notes = "查询演示账号更新日志信息分页")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "params", value = "params", dataTypeClass = String.class)
  })
  @PostMapping("/findShowUserApplyLog")
  public IPage<Map<String, Object>> findShowUserApplyLog(@RequestBody String params)
  {
    Page<Map<String, Object>> page = new Page<>();
    String conditions = MyUtil.getConditionsWhere(params, page);
    return showUserApplyService.findShowUserApplyLog(page, conditions);
  }

  @ApiOperation(value = "保存->演示账号信息", notes = "保存演示账号信息")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "params", value = "保存参数", dataTypeClass = Map.class)
  })
  @PostMapping(value = "/saveShowUserApply")
  public Map<String, Object> saveShowUserApply(@RequestBody Map<String, Object> param)
  {
    return showUserApplyService.saveShowUserApply(param);
  }

  @ApiOperation(value = "修改->演示账号信息", notes = "修改演示账号信息")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "params", value = "保存参数", dataTypeClass = Map.class)
  })
  @PutMapping(value = "/updateShowUserApply/{id}")
  public Map<String, Object> updateShowUserApply(@PathVariable("id") Long id, @RequestBody Map<String, Object> params)
  {
    return showUserApplyService.updateShowUserApply(id, params);
  }

  @ApiOperation(value = "提交->演示账号信息", notes = "提交演示账号信息")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "params", value = "保存参数", dataTypeClass = Map.class)
  })
  @PutMapping(value = "/updateSubmitShowUserApply/{id}")
  public Map<String, Object> updateSubmitShowUserApply(@PathVariable("id") Long id, @RequestBody Map<String, Object> params)
  {
    return showUserApplyService.updateSubmitShowUserApply(id, params);
  }
}
